﻿param($config='Debug')
$scriptLocation = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$solutionName = 'SPSearchBench'
$SolutionRoot = (Get-Item "$scriptLocation\$solutionName").FullName

$PagesDir = "$SolutionRoot\TEMPLATE\LAYOUTS\$solutionName\Pages"
$ControlsDir = "$SolutionRoot\TEMPLATE\CONTROLTEMPLATES\$solutionName\Controls"

write-host 'Cleaning up old assets...'
rm $SolutionRoot\*.dll -force #2> $null
rm $PagesDir\*.aspx -force #2> $null
rm $PagesDir\AJAX\*.* -force #2> $null
#rm $ControlsDir\*.ascx -force #2> $null

write-host 'Copying new assets...'
pushd "$scriptLocation\..\.."
#copy Mediacom.KnowledgeManagement.Files\Assemblies\*.dll -exclude Microsoft* $SolutionRoot -force
copy SharePointSearchBench.Deployment\bin\$config\*.dll $SolutionRoot -force
copy SharePointSearchBench.Web\bin\*.dll $SolutionRoot -force
copy SharePointSearchBench.Web\Pages\*.aspx $PagesDir -force
copy SharePointSearchBench.Web\Pages\AJAX\*.* $PagesDir\AJAX -force
#copy Mediacom.KnowledgeManagement.Web\Controls\*.ascx $ControlsDir -force
#copy Mediacom.KnowledgeManagement.Library\bin\*.dll $SolutionRoot -force
#copy Mediacom.KnowledgeManagement.Services\bin\*.dll $SolutionRoot -force

pushd $scriptLocation
. .\buildDdf.ps1 $solutionName
makecab /f "$solutionName.Auto.ddf"
popd

#ls $scriptLocation|? {$_.PSIsContainer -eq $true}|% { 
#	#copy-requiredAssemblies($_)
#	create-ddfFromFolder($_) 
#	makecab /f ($_.Parent.FullName + "\" + $_.Name + ".ddf")
#}

write-host "Done"
popd
